package com;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class TimeText {

    // yyyy-MM-dd HH:mm:ss
    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入：xxxx年xx月xx日xx时xx分xx秒");
        String next = sc.next();
        String c = next;
        // 方法一  链式编程
        String s = c.replaceAll("年", "-").replaceAll("月", "-")
                .replaceAll("日", " ").replaceAll("时", ":")
                .replaceAll("分", ":").replaceAll("秒", "");


        // 方法二
     /*   c = c.replaceAll("年","-");
        c = c.replaceAll("月","-");
        c = c.replaceAll("日","-");
        c = c.replaceAll("时",":");
        c = c.replaceAll("分",":");
        c = c.substring(0,c.length() - 1);
        String substring = c.substring(0, 10);
        c = c.substring(10);
        c = c.replaceFirst("-"," ");
        String concat = substring.concat(c);
        System.out.println(concat);*/
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
          Date date = sdf.parse(s);
            System.out.println(date.getTime());
        }catch (Exception e){
            e.printStackTrace();
        }









    }
}
